﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Text;

namespace DataContext
{
	public class AccessoryContext
	{
		#region Fields
		Database.Database db = new Database.Database(Database.Providers.SqlClient, Config.Global.Settings.ConnectionString);
		#endregion

		#region Constructors
		public AccessoryContext() {}
		#endregion

		#region Context Methods
        /// <summary>
        /// Tìm kiếm phụ kiện
        /// </summary>
        /// <param name="text"></param>
        /// <param name="currentPage"></param>
        /// <param name="pageSize"></param>
        /// <param name="totalRecord"></param>
        /// <returns></returns>
        public DataTable Search(string text, int currentPage, int pageSize, ref int totalRecord)
        {
            try
            {
                List<SqlParameter> lstParam = new List<SqlParameter>();
                lstParam.Add(new SqlParameter("@text", text));
                lstParam.Add(new SqlParameter("@CurrentPage", currentPage));
                lstParam.Add(new SqlParameter("@PageSize", pageSize));
                SqlParameter para = new SqlParameter("@TotalRecord", SqlDbType.Int);
                para.Direction = ParameterDirection.Output;
                lstParam.Add(para);

                return db.GetDataTable("[uspAccessorySearch]", lstParam.ToArray());
            }
            catch (System.Exception)
            {
            	return null;
            }
        }
		#endregion
	}
}
